{extend name="base"} {block name="content"}
<style type="text/css">
	.checkutil label{float: left;margin-right: 10px;}
</style>
	<link rel="stylesheet" href="__THEMES__/jstree/dist/themes/default/style.min.css" />
	<script src="__THEMES__/jstree/dist/jstree.min.js"></script>
	<script type="text/javascript">
	$(function(){
		$('#role_wrap').jstree({
			"core":{
				"themes":{
					"name" : "default",
					"dots" : true,
					"icons" : false
				},
				'data' : {
			        "url" : '{empty name="listUser"}{:url("menu/role")}{else/}{:url("menu/role",["privs"=>$listUser[0]["privs"]])}{/empty}',
			        "dataType" : "json"
			      }
			},
		  	"plugins" : ["checkbox"],
		});
		$('#role_wrap').on("changed.jstree", function (e, data) {
			$("#role").val(data.selected.join(","));
		});
		$("#checkall").click(function(){
			$("#role_wrap").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
		});
		$("#openall").click(function(){
			$("#role_wrap").jstree($(this).prop("checked") ? "open_all" : "close_all");
		});
	});
	</script>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Member/admin')}">管理员</a></li>
        <li><a href="{:url('Member/add')}">管理员添加</a></li>
        <li class="active"><a href="{:url('Member/priv',['id'=>$listUser[0]['id']])}">编辑权限</a></li>
    </ul>
    <form action="" method="post" class="form-horizontal js-ajax-form">
        <input type="hidden" name="id" value="{$listUser[0]['id']}" />
        <input type="hidden" name="privs" id="role" value="{$listUser[0]['privs']|default=''}" />
        <div class="control-group">
			<label class="control-label"></label>
			<div class="controls checkutil"><label><input type="checkbox" id="checkall"> 全部选中</label><label><input type="checkbox" id="openall"> 全部展开</label></div>
		</div>
        <div class="control-group">
			<label class="control-label">设置管理员 [{$listUser[0]['username']}] 的后台权限</label>
			<div class="controls" id="role_wrap"></div>
		</div>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary  js-ajax-submit">确定操作</button>
            <a class="btn" href="javascript:history.go(-1)">返回</a>
        </div>
    </form>
    <div class="pagination"></div>
</div>
<script src="__THEMES__/js/common.js"></script>
{/block}